/*
* Copyright (c) 2007 by Kirill Kolodyazhniy.
* See the file "license.terms" for information on usage and redistribution.
*/

#ifndef M_MOVABLEOBJECTVISITOR_H
#define M_MOVABLEOBJECTVISITOR_H


#include "types.h"

namespace Engine
{
	/**
	*   Abstract class for define movable objects visitors.
	*/
	class MovableObjectVisitor
	{
	public:
		virtual ~MovableObjectVisitor(){}
		virtual void Visit(Light*){}
		virtual void Visit(Entity*){}
		virtual void Visit(ParticleSystem*){}
		virtual void ToFirst() = 0;
		virtual MovableObject* GetNext() = 0;
	};

	/**
	*    Template visitor for movable objects.
	*    class specified class objects to vector.
	*/
	template<class T>
	class MovableObjectVisitorVec: public MovableObjectVisitor
	{
	public:
		MovableObjectVisitorVec():m_index(0){}

		typedef std::vector<T*> ObjectVector;

		void Visit(T* obj)
		{
			m_objectVector.push_back(obj);
		}

		void ToFirst()
		{
			m_index = 0;
		}

		MovableObject* GetNext()
		{
			if(m_index < m_objectVector.size())
				return m_objectVector[m_index++];
			return 0;
		}

	private:
		ObjectVector m_objectVector; //object holds searched objects. See Accept.
		unsigned int m_index;
	};
}

#endif
